package com.hkc.huakang.hkcpaperless;

import android.content.Context;
import android.content.SharedPreferences;

public class SharedPreferencesUtils {
    private final String XProject = "User";
    private final String USER_NAME="user_name";
    private final String USER_PASSWORD="user_password";
    private final String MYSQL_IP="IP";
    private final String DATABASE_NAME="DATABASE_NAME";
    private final String MYSQL_UserNAME="MYSQL_UserNAME";
    private final String MYSQL_PASS="MYSQL_PASS";


    public static SharedPreferencesUtils getInstance() {
        return SharedPreferencesUtilsHelp.inStance;
    }


    static class SharedPreferencesUtilsHelp {
        static SharedPreferencesUtils inStance = new SharedPreferencesUtils();
    }

    /**
     * 保存
     */
    public boolean  saveUserPassWord(Context context , String  password){
        SharedPreferences preferences = context.getSharedPreferences(XProject,
                Context.MODE_PRIVATE);
        return preferences.edit().putString(USER_PASSWORD, password).commit();
    }
    public String getUserPassWord(Context context){
        SharedPreferences preferences = context.getSharedPreferences(XProject,
                Context.MODE_PRIVATE);
        String  userJson=preferences.getString(USER_PASSWORD, "");
        return userJson;
    }
    /**
     * 保存
     */
    public boolean  saveUserName(Context context , String  username){
        SharedPreferences preferences = context.getSharedPreferences(XProject,
                Context.MODE_PRIVATE);
        return preferences.edit().putString(USER_NAME, username).commit();
    }
    public String getUserName(Context context){
        SharedPreferences preferences = context.getSharedPreferences(XProject,
                Context.MODE_PRIVATE);
        String  userJson=preferences.getString(USER_NAME, "");
        return userJson;
    }
    /**
     * 保存
     */
    public boolean  saveMysqlIP(Context context , String  mysqlIp){
        SharedPreferences preferences = context.getSharedPreferences(XProject,
                Context.MODE_PRIVATE);
        return preferences.edit().putString(MYSQL_IP, mysqlIp).commit();
    }
    public String getMysqlIP(Context context){
        SharedPreferences preferences = context.getSharedPreferences(XProject,
                Context.MODE_PRIVATE);
        String  userJson=preferences.getString(MYSQL_IP, "");
        return userJson;
    }
    /**
     * 保存
     */
    public boolean  saveDataName(Context context , String  dataName){
        SharedPreferences preferences = context.getSharedPreferences(XProject,
                Context.MODE_PRIVATE);
        return preferences.edit().putString(DATABASE_NAME, dataName).commit();
    }
    public String getDataName(Context context){
        SharedPreferences preferences = context.getSharedPreferences(XProject,
                Context.MODE_PRIVATE);
        String  userJson=preferences.getString(DATABASE_NAME, "");
        return userJson;
    }
    /**
     * 保存
     */
    public boolean  saveMYSQL_UserNAME(Context context , String  dataName){
        SharedPreferences preferences = context.getSharedPreferences(XProject,
                Context.MODE_PRIVATE);
        return preferences.edit().putString(MYSQL_UserNAME, dataName).commit();
    }
    public String getMYSQL_UserNAME(Context context){
        SharedPreferences preferences = context.getSharedPreferences(XProject,
                Context.MODE_PRIVATE);
        String  userJson=preferences.getString(MYSQL_UserNAME, "");
        return userJson;
    }    /**
     * 保存
     */
    public boolean  saveMYSQL_PASS(Context context , String  dataName){
        SharedPreferences preferences = context.getSharedPreferences(XProject,
                Context.MODE_PRIVATE);
        return preferences.edit().putString(MYSQL_PASS, dataName).commit();
    }
    public String getMYSQL_PASS(Context context){
        SharedPreferences preferences = context.getSharedPreferences(XProject,
                Context.MODE_PRIVATE);
        String  userJson=preferences.getString(MYSQL_PASS, "");
        return userJson;
    }
}
